package com.suxin.plugin.intergration.factory.process.post;

import com.suxin.plugin.intergration.factory.PluginRegistryInfo;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ConfigurationClassPostProcessor;
import org.springframework.context.support.GenericApplicationContext;

import java.util.List;

/**
 * @author Tang
 * @classname PluginConfigurePostProcessor
 * @description [  ]
 * @date 2022/7/23 14:41
 */
public class PluginConfigurePostProcessor implements PluginPostProcessor{

    private final GenericApplicationContext applicationContext;

    public PluginConfigurePostProcessor(ApplicationContext applicationContext) {
        this.applicationContext = (GenericApplicationContext)applicationContext;
    }


    @Override
    public void initialize() throws Exception {

    }

    @Override
    public void registry(List<PluginRegistryInfo> pluginRegistryInfos) throws Exception {
        ConfigurationClassPostProcessor classPostProcessor = this.applicationContext
                .getBean(ConfigurationClassPostProcessor.class);
        // 获取所有的bean,重新解析一遍
        classPostProcessor.processConfigBeanDefinitions(applicationContext);
    }

    @Override
    public void unRegistry(List<PluginRegistryInfo> pluginRegistryInfos) {

    }
}